fix(msc): correct SD SPI fops symbol name in usbd_storage_sd_spi.c#1242
Conversation
usbd_storage_sd_spi.c defined USBD_MSC_MICRO_SDIO_fops instead of USBD_MSC_MICRO_SD_SPI_fops. usb_msc_h7xx.c (and f7xx.c) reference the SPI name on the #elif USE_SDCARD_SPI branch, so any target with only USE_SDCARD_SPI (no USE_SDCARD_SDIO) failed with 'undeclared identifier'. Also caused a latent duplicate-symbol when both SDIO and SPI were enabled. Fix: rename to USBD_MSC_MICRO_SD_SPI_fops in both usbd_storage_sd_spi.c and usbd_storage.h. usbd_storage_sdio.c retains USBD_MSC_MICRO_SDIO_fops unchanged. Closes emuflight#1241.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR corrects the USB mass-storage SPI backend symbol name from ChangesSD Card SPI fops symbol correction
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Previous commit replaced USBD_MSC_MICRO_SDIO_fops in usbd_storage.h, removing the extern needed by usb_msc_f7xx.c, usb_msc_h7xx.c (SDIO branch), and usb_msc_f4xx.c. Restore it under a USE_SDCARD_SDIO guard and add the SPI fops under USE_SDCARD_SPI, matching BF 4.5-m usbd_storage.h which uses separate guards for each symbol.
Targets that define only USE_SDCARD (no sub-type, e.g. ANYFCF7) broke when the SDIO fops extern was narrowed to USE_SDCARD_SDIO. Restore the broad USE_SDCARD guard for USBD_MSC_MICRO_SDIO_fops to preserve F4/F7 backward compat; keep the new USE_SDCARD_SPI guard for the SPI fops that fixes H7 targets.
…orage.h" This reverts commit 39d5501.
This reverts commit 01cc4de.
This reverts commit 2da3031.
usb_msc_h7xx.c used USBD_MSC_MICRO_SD_SPI_fops on the USE_SDCARD_SPI branch — a symbol that does not exist in EmuFlight. EF uses USBD_MSC_MICRO_SDIO_fops as the unified SPI SD storage fops name (defined in usbd_storage_sd_spi.c). Use the existing EF symbol. Closes emuflight#1241.
|
AI Generated comment @coderabbitai, new push after prior approach was reverted. The PR is now a single-line fix: |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Get the current diff of PR `#1242`
gh pr diff 1242 --repo emuflight/EmuFlight
echo "---FILES CHANGED---"
gh pr view 1242 --repo emuflight/EmuFlight --json files --jq '.files[].path'
echo "---PR STATUS---"
gh pr view 1242 --repo emuflight/EmuFlight --json title,state,headRefName,baseRefName,bodyLength of output: 2784 🏁 Script executed: #!/bin/bash
echo "=== All references to USBD_MSC_MICRO_SD_SPI_fops ==="
rg -n "USBD_MSC_MICRO_SD_SPI_fops"
echo ""
echo "=== All references to USBD_MSC_MICRO_SDIO_fops ==="
rg -n "USBD_MSC_MICRO_SDIO_fops"
echo ""
echo "=== usb_msc_*.c files ==="
fd -e c "usb_msc_" --exec cat {}
echo ""
echo "=== usbd_storage.h ==="
fd -e h "usbd_storage" --exec cat {}Length of output: 15318
Fix correctness ✅
Consistency with F4/F7 ✅ Both Duplicate-symbol risk ✅ (no regression)
The existing Minor observation (non-blocking) After the fix, both branches of the `#ifdef` USE_SDCARD_SDIO
USBD_MSC_RegisterStorage(&USBD_Device, &USBD_MSC_MICRO_SDIO_fops);
`#elif` defined(USE_SDCARD_SPI)
USBD_MSC_RegisterStorage(&USBD_Device, &USBD_MSC_MICRO_SDIO_fops);These could be collapsed to Overall the approach is sound — minimal, targeted, and no regressions. ✅ ✏️ Learnings added
🧠 Learnings used |
Both USE_SDCARD_SDIO and USE_SDCARD_SPI branches called the same USBD_MSC_RegisterStorage line. Collapse to a single || guard, consistent with the simpler pattern in usb_msc_f4xx.c and usb_msc_f7xx.c.
AI Generated pull-request
Summary
src/main/msc/usbd_storage_sd_spi.cdefinedUSBD_MSC_MICRO_SDIO_fopsinstead ofUSBD_MSC_MICRO_SD_SPI_fops.src/main/drivers/usb_msc_h7xx.creferencesUSBD_MSC_MICRO_SD_SPI_fopson its#elif defined(USE_SDCARD_SPI)branch, so any H7 target withUSE_SDCARD_SPIonly (noUSE_SDCARD_SDIO) failed to compile:The wrong name also caused a latent duplicate-symbol when both
USE_SDCARD_SDIOandUSE_SDCARD_SPIwere defined simultaneously, since bothusbd_storage_sd_spi.candusbd_storage_sdio.cwould define the sameUSBD_MSC_MICRO_SDIO_fopssymbol.Changes:
src/main/msc/usbd_storage_sd_spi.c: renameUSBD_MSC_MICRO_SDIO_fops→USBD_MSC_MICRO_SD_SPI_fops(both HAL and legacy variants)src/main/msc/usbd_storage.h: renameexterndeclarations to matchsrc/main/msc/usbd_storage_sdio.cis unchanged — it continues to defineUSBD_MSC_MICRO_SDIO_fopscorrectly.BF 4.5-m parity:
usbd_storage_sd_spi.cin BF usesUSBD_MSC_MICRO_SD_SPI_fops.Closes #1241.
Test plan
Summary by CodeRabbit